//Sun Oct  9 13:15:38 PDT 2011
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.awt.geom.*;

/*
 * For this problem, I have build the tree for each doc with the given String array.
 * The problem here is how to find the intree for each other.
 * 
 * */
public class bloggoDocStructure {

	public Node rootA;
	public Node rootB;

	public String compare(String[] docA, String[] docB) {
		rootA = buildTree(concatenation(docA));
		rootB = buildTree(concatenation(docB));
		// display(rootA);
		return "";
	}

	public boolean isIntree(Node A, Node B) {
		boolean flag = false;
		if (A.data.compareTo(B.data) == 0) {
			List<Node> listA = A.next;
			List<Node> listB = B.next;
			if (listA.size() <= listB.size()) {
			}
		}
		return flag;
	}

	public void display(Node node) {
		if (node == null)
			return;
		System.out.print(node.data + " : ");
		for (int i = 0; i < node.next.size(); i++)
			System.out.print(node.next.get(i).data + ", ");
		System.out.println();
		for (int i = 0; i < node.next.size(); i++)
			display(node.next.get(i));
	}

	public Node buildTree(String s) {
		Node node = new Node();
		String s1 = extract(s);
		node.data = s1;
		String str = s.substring(s1.length(), s.length() - s1.length() - 1);
		while (str.length() > 0) {
			String tmp1 = extract(str);
			String tmp2 = "</" + tmp1.substring(1);
			int idx = str.indexOf(tmp2);
			String temp = str.substring(0, idx + tmp2.length());
			if (temp.length() > 0)
				node.next.add(buildTree(temp));
			str = str.substring(temp.length());
		}
		return node;
	}

	public String extract(String s) {
		if (s == null || s.length() == 0)
			return null;
		int idx1 = s.indexOf(">");
		String s1 = s.substring(0, idx1 + 1);
		// String s2 = "</" + s.substring(1, idx1) + ">";
		// int idx2 = s.indexOf(s2);
		return s1;
	}

	public String concatenation(String[] A) {
		String str = "";
		boolean flag = false;
		for (int i = 0; i < A.length; i++)
			for (int j = 0; j < A[i].length(); j++)
				if (A[i].charAt(j) == '<') {
					str += A[i].charAt(j);
					flag = true;
				} else if (A[i].charAt(j) == '>') {
					flag = false;
					str += A[i].charAt(j);
				} else if (flag)
					str += A[i].charAt(j);
		return str;
	}
	// <%:testing-code%>
}

class Node {
	public int count;
	public String data;
	public List<Node> next;

	public Node() {
		this.data = "";
		this.next = new ArrayList<Node>();
	}
}
// Powered by [KawigiEdit] 2.0!
